package com.kamistoat.ruoyiapisystem.controller;

import java.util.Arrays;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.kamistoat.ruoyiapisystem.entity.SysNoticeEntity;
import com.kamistoat.ruoyiapisystem.service.SysNoticeService;
import com.kamistoat.common.utils.PageUtils;
import com.kamistoat.common.utils.R;



/**
 * 通知公告表
 *
 * @author kamistoat
 * @email linjianshanke@163.com
 * @date 2022-08-09 10:34:45
 */
@RestController
@RequestMapping("ruoyiapisystem/sysnotice")
public class SysNoticeController {
    @Autowired
    private SysNoticeService sysNoticeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    // @RequiresPermissions("ruoyiapisystem:sysnotice:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sysNoticeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{noticeId}")
    // @RequiresPermissions("ruoyiapisystem:sysnotice:info")
    public R info(@PathVariable("noticeId") Integer noticeId){
		SysNoticeEntity sysNotice = sysNoticeService.getById(noticeId);

        return R.ok().put("sysNotice", sysNotice);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    // @RequiresPermissions("ruoyiapisystem:sysnotice:save")
    public R save(@RequestBody SysNoticeEntity sysNotice){
		sysNoticeService.save(sysNotice);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    // @RequiresPermissions("ruoyiapisystem:sysnotice:update")
    public R update(@RequestBody SysNoticeEntity sysNotice){
		sysNoticeService.updateById(sysNotice);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    // @RequiresPermissions("ruoyiapisystem:sysnotice:delete")
    public R delete(@RequestBody Integer[] noticeIds){
		sysNoticeService.removeByIds(Arrays.asList(noticeIds));

        return R.ok();
    }

}
